﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xiezl.Common.Data;
using System.Data.Entity.ModelConfiguration;

namespace Xiezl.Common.Entity
{
    public class ProductMap : EntityTypeConfiguration<Product> 
    {
        public ProductMap()
        {
            this.ToTable("Product");

            this.HasKey(t => t.Id);

            this.Property(t => t.Specification).HasMaxLength(100);
            this.Property(t => t.Code).HasMaxLength(20);
            this.Property(t => t.Name).HasMaxLength(20);
            // Relationships
            //产品类别
            this.HasRequired(t => t.ProductCategory).WithMany(t => t.Products).HasForeignKey(d => d.CategoryId);   
        }
    }
}
